using System;
using System.Collections.Generic;
using System.ByteBuffer;
using tools;

namespace thirteen
{
    /// <summary>
    /// generate by msg tool
    /// 玩家游戏记录信息
    /// </summary>
	public class ThirteenRecordInfo : Dto
	{
		//时间
		public String time;
		//总局数
		public int rounds;
		//人数
		public int players;
		//玩家最后总结算
		public List<PlayerBillInfo> items = new List<PlayerBillInfo>();
		

        public ThirteenRecordInfo() { }

        public ThirteenRecordInfo(String time, int rounds, int players)
        {
            this.time = time;
            this.rounds = rounds;
            this.players = players;
        }

        
		public void write(object obj)
		{
			ByteBuffer b = obj as ByteBuffer;
			b.PushString(time);
			b.PushInt(rounds);
			b.PushInt(players);
			b.PushInt(items.Count);

			foreach (var element in items)
			{
				element.write(b);
			}
			
		}

	    public void read(object obj)
		{
		    MyConverter b = obj as MyConverter;
			time = b.toString();
			rounds = b.toInt32();
			players = b.toInt32();
			int items_length = b.toInt32();
			for (int i = 0; i < items_length; ++i)
			{
				var dto = new PlayerBillInfo();
				dto.read(b);
				items.Add(dto);
			}
			
		}

	}
}